package com.ruoyi.materialCuttingPlan.service.impl;

import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.materialCuttingPlan.mapper.McpMaterialMapper;
import com.ruoyi.materialCuttingPlan.domain.McpMaterial;
import com.ruoyi.materialCuttingPlan.service.IMcpMaterialService;

/**
 * 型材定义Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-07-15
 */
@Service
public class McpMaterialServiceImpl implements IMcpMaterialService 
{
    @Autowired
    private McpMaterialMapper mcpMaterialMapper;

    /**
     * 查询型材定义
     * 
     * @param id 型材定义主键
     * @return 型材定义
     */
    @Override
    public McpMaterial selectMcpMaterialById(Long id)
    {
        return mcpMaterialMapper.selectMcpMaterialById(id);
    }

    /**
     * 查询型材定义列表
     * 
     * @param mcpMaterial 型材定义
     * @return 型材定义
     */
    @Override
    @DataScope(userAlias = "u")
    public List<McpMaterial> selectMcpMaterialList(McpMaterial mcpMaterial)
    {
        return mcpMaterialMapper.selectMcpMaterialList(mcpMaterial);
    }

    /**
     * 新增型材定义
     * 
     * @param mcpMaterial 型材定义
     * @return 结果
     */
    @Override
    public int insertMcpMaterial(McpMaterial mcpMaterial)
    {
        mcpMaterial.setCreateTime(DateUtils.getNowDate());
        mcpMaterial.setCreateBy(SecurityUtils.getUsername());
        mcpMaterial.setCreateById(SecurityUtils.getUserId());
        return mcpMaterialMapper.insertMcpMaterial(mcpMaterial);
    }

    /**
     * 修改型材定义
     * 
     * @param mcpMaterial 型材定义
     * @return 结果
     */
    @Override
    public int updateMcpMaterial(McpMaterial mcpMaterial)
    {
        mcpMaterial.setUpdateTime(DateUtils.getNowDate());
        mcpMaterial.setUpdateBy(SecurityUtils.getUsername());
        mcpMaterial.setUpdateById(SecurityUtils.getUserId());
        return mcpMaterialMapper.updateMcpMaterial(mcpMaterial);
    }

    /**
     * 批量删除型材定义
     * 
     * @param ids 需要删除的型材定义主键
     * @return 结果
     */
    @Override
    public int deleteMcpMaterialByIds(Long[] ids)
    {
        return mcpMaterialMapper.deleteMcpMaterialByIds(ids);
    }

    /**
     * 删除型材定义信息
     * 
     * @param id 型材定义主键
     * @return 结果
     */
    @Override
    public int deleteMcpMaterialById(Long id)
    {
        return mcpMaterialMapper.deleteMcpMaterialById(id);
    }
}
